package cn.jbolt.ai.core.chain.node.action.apicall;

import cn.jbolt.util.JSONUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.jboltai.util.http.HttpMethod;

public class ApiCallConfig {


    private String url;

    private HttpMethod method;

    private ArrayNode queryParams;

    private ArrayNode formParams;

    private ArrayNode headers;

    private String bodyType;

    private String jsonBody;

    private String rawBody;

    private ResponseType responseType;

    private String outputField;


    public static ApiCallConfig from(JsonNode jsonNode) {
        if (jsonNode == null) {
            return new ApiCallConfig();
        }
        return JSONUtil.toObject(jsonNode, ApiCallConfig.class);
    }


    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public HttpMethod getMethod() {
        return method;
    }

    public void setMethod(HttpMethod method) {
        this.method = method;
    }

    public ArrayNode getQueryParams() {
        return queryParams;
    }

    public void setQueryParams(ArrayNode queryParams) {
        this.queryParams = queryParams;
    }

    public ArrayNode getFormParams() {
        return formParams;
    }

    public void setFormParams(ArrayNode formParams) {
        this.formParams = formParams;
    }

    public ArrayNode getHeaders() {
        return headers;
    }

    public void setHeaders(ArrayNode headers) {
        this.headers = headers;
    }

    public String getBodyType() {
        return bodyType;
    }

    public void setBodyType(String bodyType) {
        this.bodyType = bodyType;
    }

    public String getRawBody() {
        return rawBody;
    }

    public void setRawBody(String rawBody) {
        this.rawBody = rawBody;
    }

    public ResponseType getResponseType() {
        return responseType;
    }

    public void setResponseType(ResponseType responseType) {
        this.responseType = responseType;
    }

    public String getOutputField() {
        return outputField;
    }

    public void setOutputField(String outputField) {
        this.outputField = outputField;
    }

    public String getJsonBody() {
        return jsonBody;
    }

    public void setJsonBody(String jsonBody) {
        this.jsonBody = jsonBody;
    }
}
